
function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if (r != null) {
        return decodeURI(r[2]);
    } else {
        return null;
    }
}
// 精确乘法
function accMul(arg1, arg2) {
    var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
    try {
        m += s1.split(".")[1].length
    } catch (e) {
    }
    try {
        m += s2.split(".")[1].length
    } catch (e) {
    }
    return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m)
}

// 精确减法
function accSub(arg1, arg2) {
    var r1, r2, m, n;
    try {
        r1 = arg1.toString().split(".")[1].length
    } catch (e) {
        r1 = 0
    }
    try {
        r2 = arg2.toString().split(".")[1].length
    } catch (e) {
        r2 = 0
    }
    m = Math.pow(10, Math.max(r1, r2));
    n = (r1 >= r2) ? r1 : r2;
    return ((arg1 * m - arg2 * m) / m);
}

// 精确加法
function accAdd(arg1, arg2) {
    var r1, r2, m;
    try {
        r1 = arg1.toString().split(".")[1].length;
    } catch (e) {
        r1 = 0;
    }
    try {
        r2 = arg2.toString().split(".")[1].length;
    } catch (e) {
        r2 = 0;
    }
    m = Math.pow(10, Math.max(r1, r2));
    return (arg1 * m + arg2 * m) / m;
}

// 精确除法
function accDiv(arg1, arg2) {
    var t1 = 0, t2 = 0, r1, r2;
    try {
        t1 = arg1.toString().split(".")[1].length;
    } catch (e) {
    }
    try {
        t2 = arg2.toString().split(".")[1].length;
    } catch (e) {
    }
    with (Math) {
        r1 = Number(arg1.toString().replace(".", ""));
        r2 = Number(arg2.toString().replace(".", ""));
        return (r1 / r2) * pow(10, t2 - t1);
    }
}


//保留两位小数
function toFixed2(str) {
    return parseFloat(str).toFixed(2);
}



//公用ajajx
var ajaxverA = 0, ajaxverB = 0, timejson = null, setwait = null, is_ajax_send = 0, i_index;
var loadH = $("<i class='loadmaks' style='position: fixed; background: rgba(0,0,0,0); left: 0; top: 0; z-index: 1000000000000; height: 100%; width: 100%;'></i>")
function global_ajax(url, data, call) {
    if (is_ajax_send) {
        return false;
    }
    is_ajax_send = 1;
    if (ajaxverA == 0 && ajaxverB == 0) {
        $("body").append(loadH)
        timejson = setInterval(function () {
            i_index = layer.load();
            clearInterval(timejson);
        }, 700);
    }
    ajaxverA++;
    $.ajax({
        type: "post",
        dataType: "json",
        timeout: 15000,
        url: url,
        data: data,
        cache: false,
        success: function (h) {
            layer.close(i_index);
            is_ajax_send = 0;
            ajaxverB++;
            if (ajaxverA == ajaxverB)
            {
                loadH.remove();
                clearInterval(timejson);
                ajaxverA = 0;
                ajaxverB = 0;
            }
            call(h);
        },
        error: function (e) {
            is_ajax_send = 0;
            ajaxverB++;
            if (ajaxverA == ajaxverB)
            {
                loadH.remove();
                clearInterval(timejson);
                ajaxverA = 0;
                ajaxverB = 0;
            }
            mui.toast('接口加载错误');
        }
    });
}

//获取cookie
function getCookie(name) {
        var arr, reg = new RegExp("(^| )" + name + "=([^;]*)(;|$)");
        if (arr = document.cookie.match(reg))
            return unescape(arr[2]);
        else
            return "null";
}

//设置cookie
function setCookie(name,value,Days) 
{ 
    var exp = new Date(); 
    if(Days>0){
    exp.setTime(exp.getTime() + Days*24*60*60*1000); 
    }
    else{
            exp.setTime(-1); 
    }
    document.cookie = name + "="+ escape (value) + ";expires=" + exp.toGMTString()+";path=/"; 
}

//删除cookie
function delCookie(name)
{
    var exp = new Date();
    exp.setTime(exp.getTime() - 1);
    var cval=getCookie(name);
    if(cval!=null)
        document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString() + ";path=/";
}

//删除所有cookie
 function clearCookie() {
     var keys = document.cookie.match(/[^ =;]+(?=\=)/g);
     if (keys) {
         for (var i = keys.length; i--;) {
             document.cookie = keys[i] + '=0;expires=' + new Date(0).toUTCString() + "; path=/"
         }
     }
 }
//调整初始化字号



//注册选择地区
var reg_datas=[
    {
        "text": "Malaysia+60",
        "value": "60"
    },
    {
        "text": "Singapore+65",
        "value": "65"
    },
    {
        "text": "China (中国)+86",
        "value": "86"
    },
    {
        "text": "Taiwan (台灣)+886",
        "value": "886"
    },
    {
        "text": "Hong Kong (香港)+852",
        "value": "852"
    },
    {
        "text": "India (भारत)+91",
        "value": "91"
    },
    {
        "text": "Indonesia+62",
        "value": "62"
    },
    {
        "text": "Philippines+63",
        "value": "63"
    },
    {
        "text": "United States+1",
        "value": "1"
    },
    {
        "text": "United Kingdom+44",
        "value": "44"
    },
    {
        "text": "Japan (日本)+81",
        "value": "81"
    },
    {
        "text": "Thailand (ไทย)+66",
        "value": "66"
    },
    {
        "text": "South Korea (대한민국)+82",
        "value": "82"
    },
    {
        "text": "Afghanistan (‫افغانستان‬‎)+93",
        "value": "93"
    },
    {
        "text": "Albania (Shqipëri)+355",
        "value": "355"
    },
    {
        "text": "Algeria (‫الجزائر‬‎)+213",
        "value": "213"
    },
    {
        "text": "American Samoa+1684",
        "value": "1684"
    },
    {
        "text": "Andorra+376",
        "value": "376"
    },
    {
        "text": "Angola+244",
        "value": "244"
    },
    {
        "text": "Anguilla+1264",
        "value": "1264"
    },
    {
        "text": "Antigua and Barbuda+1268",
        "value": "1268"
    },
    {
        "text": "Argentina+54",
        "value": "54"
    },
    {
        "text": "Armenia (Հայաստան)+374",
        "value": "374"
    },
    {
        "text": "Aruba+297",
        "value": "297"
    },
    {
        "text": "Australia+61",
        "value": "61"
    },
    {
        "text": "Austria (Österreich)+43",
        "value": "43"
    },
    {
        "text": "Azerbaijan (Azərbaycan)+994",
        "value": "994"
    },
    {
        "text": "Bahamas+1242",
        "value": "1242"
    },
    {
        "text": "Bahrain (‫البحرين‬‎)+973",
        "value": "973"
    },
    {
        "text": "Bangladesh (বাংলাদেশ)+880",
        "value": "880"
    },
    {
        "text": "Barbados+1246",
        "value": "1246"
    },
    {
        "text": "Belarus (Беларусь)+375",
        "value": "375"
    },
    {
        "text": "Belgium (België)+32",
        "value": "32"
    },
    {
        "text": "Belize+501",
        "value": "501"
    },
    {
        "text": "Benin (Bénin)+229",
        "value": "229"
    },
    {
        "text": "Bermuda+1441",
        "value": "1441"
    },
    {
        "text": "Bhutan (འབྲུག)+975",
        "value": "975"
    },
    {
        "text": "Bolivia+591",
        "value": "591"
    },
    {
        "text": "Bosnia and Herzegovina (Босна и Херцеговина)+387",
        "value": "387"
    },
    {
        "text": "Botswana+267",
        "value": "267"
    },
    {
        "text": "Brazil (Brasil)+55",
        "value": "55"
    },
    {
        "text": "British Indian Ocean Territory+246",
        "value": "246"
    },
    {
        "text": "British Virgin Islands+1284",
        "value": "1284"
    },
    {
        "text": "Brunei+673",
        "value": "673"
    },
    {
        "text": "Bulgaria (България)+359",
        "value": "359"
    },
    {
        "text": "Burkina Faso+226",
        "value": "226"
    },
    {
        "text": "Burundi (Uburundi)+257",
        "value": "257"
    },
    {
        "text": "Cambodia (កម្ពុជា)+855",
        "value": "855"
    },
    {
        "text": "Cameroon (Cameroun)+237",
        "value": "237"
    },
    {
        "text": "Canada+1",
        "value": "1"
    },
    {
        "text": "Cape Verde (Kabu Verdi)+238",
        "value": "238"
    },
    {
        "text": "Caribbean Netherlands+599",
        "value": "599"
    },
    {
        "text": "Cayman Islands+1345",
        "value": "1345"
    },
    {
        "text": "Central African Republic (République centrafricaine)+236",
        "value": "236"
    },
    {
        "text": "Chad (Tchad)+235",
        "value": "235"
    },
    {
        "text": "Chile+56",
        "value": "56"
    },
    {
        "text": "Christmas Island+61",
        "value": "61"
    },
    {
        "text": "Cocos (Keeling) Islands+61",
        "value": "61"
    },
    {
        "text": "Colombia+57",
        "value": "57"
    },
    {
        "text": "Comoros (‫جزر القمر‬‎)+269",
        "value": "269"
    },
    {
        "text": "Congo (DRC) (Jamhuri ya Kidemokrasia ya Kongo)+243",
        "value": "243"
    },
    {
        "text": "Congo (Republic) (Congo-Brazzaville)+242",
        "value": "242"
    },
    {
        "text": "Cook Islands+682",
        "value": "682"
    },
    {
        "text": "Costa Rica+506",
        "value": "506"
    },
    {
        "text": "Côte d’Ivoire+225",
        "value": "225"
    },
    {
        "text": "Croatia (Hrvatska)+385",
        "value": "385"
    },
    {
        "text": "Cuba+53",
        "value": "53"
    },
    {
        "text": "Curaçao+599",
        "value": "599"
    },
    {
        "text": "Cyprus (Κύπρος)+357",
        "value": "357"
    },
    {
        "text": "Czech Republic (Česká republika)+420",
        "value": "420"
    },
    {
        "text": "Denmark (Danmark)+45",
        "value": "45"
    },
    {
        "text": "Djibouti+253",
        "value": "253"
    },
    {
        "text": "Dominica+1767",
        "value": "1767"
    },
    {
        "text": "Dominican Republic (República Dominicana)+1",
        "value": "1"
    },
    {
        "text": "Ecuador+593",
        "value": "593"
    },
    {
        "text": "Egypt (‫مصر‬‎)+20",
        "value": "20"
    },
    {
        "text": "El Salvador+503",
        "value": "503"
    },
    {
        "text": "Equatorial Guinea (Guinea Ecuatorial)+240",
        "value": "240"
    },
    {
        "text": "Eritrea+291",
        "value": "291"
    },
    {
        "text": "Estonia (Eesti)+372",
        "value": "372"
    },
    {
        "text": "Ethiopia+251",
        "value": "251"
    },
    {
        "text": "Falkland Islands (Islas Malvinas)+500",
        "value": "500"
    },
    {
        "text": "Faroe Islands (Føroyar)+298",
        "value": "298"
    },
    {
        "text": "Fiji+679",
        "value": "679"
    },
    {
        "text": "Finland (Suomi)+358",
        "value": "358"
    },
    {
        "text": "France+33",
        "value": "33"
    },
    {
        "text": "French Guiana (Guyane française)+594",
        "value": "594"
    },
    {
        "text": "French Polynesia (Polynésie française)+689",
        "value": "689"
    },
    {
        "text": "Gabon+241",
        "value": "241"
    },
    {
        "text": "Gambia+220",
        "value": "220"
    },
    {
        "text": "Georgia (საქართველო)+995",
        "value": "995"
    },
    {
        "text": "Germany (Deutschland)+49",
        "value": "49"
    },
    {
        "text": "Ghana (Gaana)+233",
        "value": "233"
    },
    {
        "text": "Gibraltar+350",
        "value": "350"
    },
    {
        "text": "Greece (Ελλάδα)+30",
        "value": "30"
    },
    {
        "text": "Greenland (Kalaallit Nunaat)+299",
        "value": "299"
    },
    {
        "text": "Grenada+1473",
        "value": "1473"
    },
    {
        "text": "Guadeloupe+590",
        "value": "590"
    },
    {
        "text": "Guam+1671",
        "value": "1671"
    },
    {
        "text": "Guatemala+502",
        "value": "502"
    },
    {
        "text": "Guernsey+44",
        "value": "44"
    },
    {
        "text": "Guinea (Guinée)+224",
        "value": "224"
    },
    {
        "text": "Guinea-Bissau (Guiné Bissau)+245",
        "value": "245"
    },
    {
        "text": "Guyana+592",
        "value": "592"
    },
    {
        "text": "Haiti+509",
        "value": "509"
    },
    {
        "text": "Honduras+504",
        "value": "504"
    },
    {
        "text": "Hungary (Magyarország)+36",
        "value": "36"
    },
    {
        "text": "Iceland (Ísland)+354",
        "value": "354"
    },
    {
        "text": "Iran (‫ایران‬‎)+98",
        "value": "98"
    },
    {
        "text": "Iraq (‫العراق‬‎)+964",
        "value": "964"
    },
    {
        "text": "Ireland+353",
        "value": "353"
    },
    {
        "text": "Isle of Man+44",
        "value": "44"
    },
    {
        "text": "Israel (‫ישראל‬‎)+972",
        "value": "972"
    },
    {
        "text": "Italy (Italia)+39",
        "value": "39"
    },
    {
        "text": "Jamaica+1876",
        "value": "1876"
    },
    {
        "text": "Jersey+44",
        "value": "44"
    },
    {
        "text": "Jordan (‫الأردن‬‎)+962",
        "value": "962"
    },
    {
        "text": "Kazakhstan (Казахстан)+7",
        "value": "7"
    },
    {
        "text": "Kenya+254",
        "value": "254"
    },
    {
        "text": "Kiribati+686",
        "value": "686"
    },
    {
        "text": "Kosovo+383",
        "value": "383"
    },
    {
        "text": "Kuwait (‫الكويت‬‎)+965",
        "value": "965"
    },
    {
        "text": "Kyrgyzstan (Кыргызстан)+996",
        "value": "996"
    },
    {
        "text": "Laos (ລາວ)+856",
        "value": "856"
    },
    {
        "text": "Latvia (Latvija)+371",
        "value": "371"
    },
    {
        "text": "Lebanon (‫لبنان‬‎)+961",
        "value": "961"
    },
    {
        "text": "Lesotho+266",
        "value": "266"
    },
    {
        "text": "Liberia+231",
        "value": "231"
    },
    {
        "text": "Libya (‫ليبيا‬‎)+218",
        "value": "218"
    },
    {
        "text": "Liechtenstein+423",
        "value": "423"
    },
    {
        "text": "Lithuania (Lietuva)+370",
        "value": "370"
    },
    {
        "text": "Luxembourg+352",
        "value": "352"
    },
    {
        "text": "Macau (澳門)+853",
        "value": "853"
    },
    {
        "text": "Macedonia (FYROM) (Македонија)+389",
        "value": "389"
    },
    {
        "text": "Madagascar (Madagasikara)+261",
        "value": "261"
    },
    {
        "text": "Malawi+265",
        "value": "265"
    },
    {
        "text": "Maldives+960",
        "value": "960"
    },
    {
        "text": "Mali+223",
        "value": "223"
    },
    {
        "text": "Malta+356",
        "value": "356"
    },
    {
        "text": "Marshall Islands+692",
        "value": "692"
    },
    {
        "text": "Martinique+596",
        "value": "596"
    },
    {
        "text": "Mauritania (‫موريتانيا‬‎)+222",
        "value": "222"
    },
    {
        "text": "Mauritius (Moris)+230",
        "value": "230"
    },
    {
        "text": "Mayotte+262",
        "value": "262"
    },
    {
        "text": "Mexico (México)+52",
        "value": "52"
    },
    {
        "text": "Micronesia+691",
        "value": "691"
    },
    {
        "text": "Moldova (Republica Moldova)+373",
        "value": "373"
    },
    {
        "text": "Monaco+377",
        "value": "377"
    },
    {
        "text": "Mongolia (Монгол)+976",
        "value": "976"
    },
    {
        "text": "Montenegro (Crna Gora)+382",
        "value": "382"
    },
    {
        "text": "Montserrat+1664",
        "value": "1664"
    },
    {
        "text": "Morocco (‫المغرب‬‎)+212",
        "value": "212"
    },
    {
        "text": "Mozambique (Moçambique)+258",
        "value": "258"
    },
    {
        "text": "Myanmar (Burma) (မြန်မာ)+95",
        "value": "95"
    },
    {
        "text": "Namibia (Namibië)+264",
        "value": "264"
    },
    {
        "text": "Nauru+674",
        "value": "674"
    },
    {
        "text": "Nepal (नेपाल)+977",
        "value": "977"
    },
    {
        "text": "Netherlands (Nederland)+31",
        "value": "31"
    },
    {
        "text": "New Caledonia (Nouvelle-Calédonie)+687",
        "value": "687"
    },
    {
        "text": "New Zealand+64",
        "value": "64"
    },
    {
        "text": "Nicaragua+505",
        "value": "505"
    },
    {
        "text": "Niger (Nijar)+227",
        "value": "227"
    },
    {
        "text": "Nigeria+234",
        "value": "234"
    },
    {
        "text": "Niue+683",
        "value": "683"
    },
    {
        "text": "Norfolk Island+672",
        "value": "672"
    },
    {
        "text": "North Korea (조선 민주주의 인민 공화국)+850",
        "value": "850"
    },
    {
        "text": "Northern Mariana Islands+1670",
        "value": "1670"
    },
    {
        "text": "Norway (Norge)+47",
        "value": "47"
    },
    {
        "text": "Oman (‫عُمان‬‎)+968",
        "value": "968"
    },
    {
        "text": "Pakistan (‫پاکستان‬‎)+92",
        "value": "92"
    },
    {
        "text": "Palau+680",
        "value": "680"
    },
    {
        "text": "Palestine (‫فلسطين‬‎)+970",
        "value": "970"
    },
    {
        "text": "Panama (Panamá)+507",
        "value": "507"
    },
    {
        "text": "Papua New Guinea+675",
        "value": "675"
    },
    {
        "text": "Paraguay+595",
        "value": "595"
    },
    {
        "text": "Peru (Perú)+51",
        "value": "51"
    },
    {
        "text": "Poland (Polska)+48",
        "value": "48"
    },
    {
        "text": "Portugal+351",
        "value": "351"
    },
    {
        "text": "Puerto Rico+1",
        "value": "1"
    },
    {
        "text": "Qatar (‫قطر‬‎)+974",
        "value": "974"
    },
    {
        "text": "Réunion (La Réunion)+262",
        "value": "262"
    },
    {
        "text": "Romania (România)+40",
        "value": "40"
    },
    {
        "text": "Russia (Россия)+7",
        "value": "7"
    },
    {
        "text": "Rwanda+250",
        "value": "250"
    },
    {
        "text": "Saint Barthélemy (Saint-Barthélemy)+590",
        "value": "590"
    },
    {
        "text": "Saint Helena+290",
        "value": "290"
    },
    {
        "text": "Saint Kitts and Nevis+1869",
        "value": "1869"
    },
    {
        "text": "Saint Lucia+1758",
        "value": "1758"
    },
    {
        "text": "Saint Martin (Saint-Martin (partie française))+590",
        "value": "590"
    },
    {
        "text": "Saint Pierre and Miquelon (Saint-Pierre-et-Miquelon)+508",
        "value": "508"
    },
    {
        "text": "Saint Vincent and the Grenadines+1784",
        "value": "1784"
    },
    {
        "text": "Samoa+685",
        "value": "685"
    },
    {
        "text": "San Marino+378",
        "value": "378"
    },
    {
        "text": "São Tomé and Príncipe (São Tomé e Príncipe)+239",
        "value": "239"
    },
    {
        "text": "Saudi Arabia (‫المملكة العربية السعودية‬‎)+966",
        "value": "966"
    },
    {
        "text": "Senegal (Sénégal)+221",
        "value": "221"
    },
    {
        "text": "Serbia (Србија)+381",
        "value": "381"
    },
    {
        "text": "Seychelles+248",
        "value": "248"
    },
    {
        "text": "Sierra Leone+232",
        "value": "232"
    },
    {
        "text": "Sint Maarten+1721",
        "value": "1721"
    },
    {
        "text": "Slovakia (Slovensko)+421",
        "value": "421"
    },
    {
        "text": "Slovenia (Slovenija)+386",
        "value": "386"
    },
    {
        "text": "Solomon Islands+677",
        "value": "677"
    },
    {
        "text": "Somalia (Soomaaliya)+252",
        "value": "252"
    },
    {
        "text": "South Africa+27",
        "value": "27"
    },
    {
        "text": "South Sudan (‫جنوب السودان‬‎)+211",
        "value": "211"
    },
    {
        "text": "Spain (España)+34",
        "value": "34"
    },
    {
        "text": "Sri Lanka (ශ්‍රී ලංකාව)+94",
        "value": "94"
    },
    {
        "text": "Sudan (‫السودان‬‎)+249",
        "value": "249"
    },
    {
        "text": "Suriname+597",
        "value": "597"
    },
    {
        "text": "Svalbard and Jan Mayen+47",
        "value": "47"
    },
    {
        "text": "Swaziland+268",
        "value": "268"
    },
    {
        "text": "Sweden (Sverige)+46",
        "value": "46"
    },
    {
        "text": "Switzerland (Schweiz)+41",
        "value": "41"
    },
    {
        "text": "Syria (‫سوريا‬‎)+963",
        "value": "963"
    },
    {
        "text": "Tajikistan+992",
        "value": "992"
    },
    {
        "text": "Tanzania+255",
        "value": "255"
    },
    {
        "text": "Timor-Leste+670",
        "value": "670"
    },
    {
        "text": "Togo+228",
        "value": "228"
    },
    {
        "text": "Tokelau+690",
        "value": "690"
    },
    {
        "text": "Tonga+676",
        "value": "676"
    },
    {
        "text": "Trinidad and Tobago+1868",
        "value": "1868"
    },
    {
        "text": "Tunisia (‫تونس‬‎)+216",
        "value": "216"
    },
    {
        "text": "Turkey (Türkiye)+90",
        "value": "90"
    },
    {
        "text": "Turkmenistan+993",
        "value": "993"
    },
    {
        "text": "Turks and Caicos Islands+1649",
        "value": "1649"
    },
    {
        "text": "Tuvalu+688",
        "value": "688"
    },
    {
        "text": "U.S. Virgin Islands+1340",
        "value": "1340"
    },
    {
        "text": "Uganda+256",
        "value": "256"
    },
    {
        "text": "Ukraine (Україна)+380",
        "value": "380"
    },
    {
        "text": "United Arab Emirates (‫الإمارات العربية المتحدة‬‎)+971",
        "value": "971"
    },
    {
        "text": "Uruguay+598",
        "value": "598"
    },
    {
        "text": "Uzbekistan (Oʻzbekiston)+998",
        "value": "998"
    },
    {
        "text": "Vanuatu+678",
        "value": "678"
    },
    {
        "text": "Vatican City (Città del Vaticano)+39",
        "value": "39"
    },
    {
        "text": "Venezuela+58",
        "value": "58"
    },
    {
        "text": "Vietnam (Việt Nam)+84",
        "value": "84"
    },
    {
        "text": "Wallis and Futuna+681",
        "value": "681"
    },
    {
        "text": "Western Sahara (‫الصحراء الغربية‬‎)+212",
        "value": "212"
    },
    {
        "text": "Yemen (‫اليمن‬‎)+967",
        "value": "967"
    },
    {
        "text": "Zambia+260",
        "value": "260"
    },
    {
        "text": "Zimbabwe+263",
        "value": "263"
    },
    {
        "text": "Åland Islands+358",
        "value": "358"
    }
]
